﻿define([
    'Wjs/ui/elements/Element',
    'Wjs/ui/elements/mixins/MultipleContainer'
],
function () {
    'use strict';

    return Wjs.define({

        type: 'body',

        internal: {

            'static': true,

            base: Wjs.getType('Element'),

            mixins: [
                Wjs.getType('MultipleContainer')
            ]
        },

        domEl: document.body,

        droppable: true,

        onDrop: function (evt) {

            var view = dragDropManager.getViews()[0],
                coord,
                left,
                top;

            if (view) {

                coord = evt.dataTransfer.getData('text/plain').split(',');
                left = parseFloat(coord[0]) + evt.clientX;
                top = parseFloat(coord[1]) + evt.clientY;

                view.setLeft(left);
                view.setTop(top);

                dragDropManager.clear();
            }
        },

        // Returns the width (visible and hidden) of the web page
        getPageWidth: function () {

            return this.getDomElement().scrollWidth;
        },

        // Returns the height (visible and hidden) of the web page
        getPageHeight: function () {

            return this.getDomElement().scrollHeight;
        },

        getScrollX: function () {

            return this.getDomElement().scrollLeft;
        },

        getScrollY: function () {

            return this.getDomElement().scrollTop;
        },

        getViewportWidth: function () {

            return this.getDomElement().clientWidth;
        },

        getViewportHeight: function () {

            return this.getDomElement().clientHeight;
        }

    });

});